package com.garry.security.filter;

import com.garry.constants.Constants;
import com.garry.user.entity.User;
import com.garry.user.repository.UserRepository;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.web.filter.PathMatchingFilter;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

/**
 * Created by GarryGe on 2016/12/1.
 */
public class SysUserFilter extends PathMatchingFilter{

    @Autowired
    private UserRepository userRepository;

    @Override
    protected boolean onPreHandle(ServletRequest request, ServletResponse response, Object mappedValue)
            throws Exception {

        String username = (String) SecurityUtils.getSubject().getPrincipal();
        //User user = userRepository.findByUsername(username);
        //request.setAttribute(Constants.CURRENT_USER, user);
        return true;
    }
}
